
<!DOCTYPE html>
<html lang="zh-Hans" class="loading">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>30 Seconds of ES6 （一） - 默默默默燃</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="google" content="notranslate" />
    <meta name="keywords" content="TriDiamond Obsidian,"> 
    <meta name="description" content="一枚前端搬砖队队员的记录册,项目背景简介30 seconds of code  是一个非常优质精选的 JavaScript 项目 ，总结了大量的使用 ES6  语法实现的代码块，项目的设计目标就是更简洁，更高效，更快速的实现基,"> 
    <meta name="author" content="张白告丶"> 
    <link rel="alternative" href="atom.xml" title="默默默默燃" type="application/atom+xml"> 
    <link rel="icon" href="/img/favicon.png"> 
    <link href="https://fonts.loli.net/css?family=Roboto+Mono|Rubik&display=swap" rel="stylesheet">
    
<link rel="stylesheet" href="//at.alicdn.com/t/font_1429596_nzgqgvnmkjb.css">

    
<link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.7.2/animate.min.css">

    
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/css/share.min.css">

    
<link rel="stylesheet" href="//cdn.bootcss.com/codemirror/5.48.4/codemirror.min.css">

    
<link rel="stylesheet" href="//cdn.bootcss.com/codemirror/5.48.4/theme/dracula.css">

    
<link rel="stylesheet" href="/css/obsidian.css">

    
<link rel="stylesheet" href="/css/ball-atom.min.css">

<meta name="generator" content="Hexo 4.2.0"></head>


<body class="loading">
    <div class="loader">
        <div class="la-ball-atom la-2x">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
    <span id="config-title" style="display:none">默默默默燃</span>
    <div id="loader"></div>
    <div id="single">
    <div class="scrollbar gradient-bg-rev"></div>
<div id="top" style="display: block;">
    <div class="bar" style="width: 0;"></div>
    <div class="navigation animated fadeIn fast delay-1s">
        <img id="home-icon" class="icon-home" src="/img/favicon.png" alt="" data-url="https://zhanghao-web.github.io">
        <div id="play-icon" title="Play/Pause" class="iconfont icon-play"></div>
        <h3 class="subtitle">30 Seconds of ES6 （一）</h3>
        <div class="social">
            <!--        <div class="like-icon">-->
            <!--            <a href="javascript:;" class="likeThis active"><span class="icon-like"></span><span class="count">76</span></a>-->
            <!--        </div>-->
            <div>
                <div class="share">
                    
                        <a href="javascript:;" class="iconfont icon-share1"></a>
                        <div class="share-component-cc" data-disabled="facebook,douban,linkedin,diandian,tencent,google"></div>
                    
                </div>
            </div>
        </div>
    </div>
</div>

    <div class="section">
        <div class=article-header-wrapper>
    <div class="article-header">
        <div class="article-cover animated fadeIn" style="
            animation-delay: 600ms;
            animation-duration: 1.2s;
            background-image: 
                radial-gradient(ellipse closest-side, rgba(0, 0, 0, 0.65), #100e17),
                url(/img/cover.jpg) ">
        </div>
        <div class="else">
            <p class="animated fadeInDown">
                
                <a href="/categories/Js"><b>「
                    </b>JS<b> 」</b></a>
                
                January 27, 2019
            </p>
            <h3 class="post-title animated fadeInDown"><a href="/2019/01/27/Js/30-Seconds-of-ES6-%EF%BC%88%E4%B8%80%EF%BC%89/" title="30 Seconds of ES6 （一）" class="">30 Seconds of ES6 （一）</a>
            </h3>
            
            <p class="post-count animated fadeInDown">
                
                <span>
                    <b class="iconfont icon-text2"></b> <i>Words count</i>
                    14k
                </span>
                
                
                <span>
                    <b class="iconfont icon-timer__s"></b> <i>Reading time</i>
                    13 mins.
                </span>
                
                
                
                <span id="busuanzi_container_page_pv">
                    <b class="iconfont icon-read"></b> <i>Read count</i>
                    <span id="busuanzi_value_page_pv">0</span>
                </span>
                
            </p>
            
            
            <ul class="animated fadeInDown post-tags-list" itemprop="keywords"><li class="animated fadeInDown post-tags-list-item"><a class="animated fadeInDown post-tags-list-link" href="/tags/Es6/" rel="tag">Es6</a></li></ul>
            
        </div>
    </div>
</div>

<div class="screen-gradient-after">
    <div class="screen-gradient-content">
        <div class="screen-gradient-content-inside">
            <div class="bold-underline-links screen-gradient-sponsor">
                <p>
                    <span class="animated fadeIn delay-1s"></span>
                </p>
            </div>
        </div>
    </div>
</div>

<div class="article">
    <div class='main'>
        <div class="content markdown animated fadeIn">
            <h1 id="项目背景简介"><a href="#项目背景简介" class="headerlink" title="项目背景简介"></a>项目背景简介</h1><p><a href="https://github.com/30-seconds/30-seconds-of-code" target="_blank" rel="noopener">30 seconds of code</a>  是一个非常优质精选的 JavaScript 项目 ，总结了大量的使用 ES6  语法实现的代码块，项目的设计目标就是更简洁，更高效，更快速的实现基础代码模块，碎片化学习实用干货， 30 秒掌握一个高质量 ES6 代码块 。</p>
<h2 id="学习初衷"><a href="#学习初衷" class="headerlink" title="学习初衷"></a>学习初衷</h2><p>学习 ES6 基础知识，提升程序算法能力；学习 JavaScript 基础从 API 开始。<br>每篇精选 5 段优秀代码块，和 5 个以上 API ，为前端大全栈打下坚实根基！</p>
<h2 id="学习方法"><a href="#学习方法" class="headerlink" title="学习方法"></a>学习方法</h2><p>认真解读英文版 30 seconds of code 的每个 ES6 代码块，并把其中的 API 重点分析。<br>认识新单词，提升英语水平，目标可以轻松翻阅英文版专业书，全面提升前端技术软实力。</p>
<h3 id="Adapter-适配器-ary"><a href="#Adapter-适配器-ary" class="headerlink" title="Adapter 适配器 ary"></a>Adapter 适配器 ary</h3><p>创建一个接受最多 n 个参数的函数，忽略任何其他参数。使用 <code>Array.prototype.slice（0，n）</code> 方法和 spread 扩展运算符 （…） 调用提供的函数 fn （最多 n 个参数）。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> ary = <span class="function">(<span class="params">fn , n</span>) =&gt;</span> <span class="function">(<span class="params">...args</span>) =&gt;</span> fn(...args.slice(<span class="number">0</span>, n));</span><br><span class="line"><span class="keyword">const</span> firstTwoMax = ary(<span class="built_in">Math</span>.max, <span class="number">2</span>);</span><br><span class="line"><span class="built_in">console</span>.log([[<span class="number">2</span>, <span class="number">6</span>, <span class="string">'a'</span>], [<span class="number">8</span>, <span class="number">4</span>, <span class="number">6</span>], [<span class="number">10</span>]].map(<span class="function"><span class="params">x</span> =&gt;</span> firstTwoMax(...x)));<span class="comment">//[6, 8, 10]</span></span><br></pre></td></tr></table></figure>
<h3 id="MDN-解析-Array-prototype-slice-案例"><a href="#MDN-解析-Array-prototype-slice-案例" class="headerlink" title="MDN 解析 Array.prototype.slice() 案例"></a>MDN 解析 Array.prototype.slice() 案例</h3><p>该 slice() 方法返回一个阵列的一部分的一个浅拷贝，到选自新的数组对象 begin 到 end ( end 不包括)。原始数组不会被修改。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> animals = [<span class="string">'ant'</span>, <span class="string">'bison'</span>, <span class="string">'camel'</span>, <span class="string">'duck'</span>, <span class="string">'elephant'</span>];</span><br><span class="line"><span class="built_in">console</span>.log(animals.slice(<span class="number">2</span>,<span class="number">4</span>));<span class="comment">//['camel', 'duck']</span></span><br><span class="line"><span class="built_in">console</span>.log(animals);<span class="comment">// ["ant", "bison", "camel", "duck", "elephant"]</span></span><br></pre></td></tr></table></figure>
<h3 id="MDN-解析-Math-max-案例"><a href="#MDN-解析-Math-max-案例" class="headerlink" title="MDN 解析 Math.max() 案例"></a>MDN 解析 Math.max() 案例</h3><p>该 Math.max() 函数返回零个或多个数字中的最大值。</p>
<p>console.log(Math.max(-10, 20)); //20</p>
<h3 id="Array-数组-all"><a href="#Array-数组-all" class="headerlink" title="Array   数组   all"></a>Array   数组   all</h3><p>如果提供的谓词函数对集合中的所有元素都返回  true ，则返回  true，否则返回 false 。使用   Array.prototype.every（） 测试集合中的所有元素是否基于  fn  返回  true  。省略第二个参数  fn  ，将布尔值用作默认值。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> all = <span class="function">(<span class="params">arr, fn = <span class="built_in">Boolean</span></span>) =&gt;</span> arr.every(fn);</span><br><span class="line"><span class="built_in">console</span>.log(all);</span><br><span class="line"><span class="built_in">console</span>.log(all([<span class="number">4</span>, <span class="number">2</span>, <span class="number">3</span>], x =&gt; x &gt;<span class="number">1</span>));<span class="comment">//true</span></span><br><span class="line"><span class="built_in">console</span>.log(all([<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]));<span class="comment">//true</span></span><br></pre></td></tr></table></figure>
<h3 id="MDN-解析-Array-prototype-every-案例"><a href="#MDN-解析-Array-prototype-every-案例" class="headerlink" title="MDN  解析 Array.prototype.every()  案例"></a>MDN  解析 Array.prototype.every()  案例</h3><p>该  every()  方法测试数组中的所有元素是否都通过了由提供的函数实现的测试。对于空数组，任何情况下调用该方法都会返回 true。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">console</span>.log([<span class="number">12</span>, <span class="number">5</span>, <span class="number">8</span>, <span class="number">130</span>, <span class="number">44</span>].every(<span class="function"><span class="params">x</span> =&gt;</span> x &gt;= <span class="number">10</span>));<span class="comment">//false</span></span><br><span class="line"><span class="built_in">console</span>.log([<span class="number">12</span>, <span class="number">54</span>, <span class="number">18</span>, <span class="number">130</span>, <span class="number">44</span>].every(<span class="function"><span class="params">x</span> =&gt;</span> x &gt;=<span class="number">10</span>));<span class="comment">//true</span></span><br><span class="line"><span class="built_in">console</span>.log([].every(<span class="function"><span class="params">x</span> =&gt;</span> x));<span class="comment">//true</span></span><br></pre></td></tr></table></figure>
<h3 id="Array-数组-allEqual"><a href="#Array-数组-allEqual" class="headerlink" title="Array   数组   allEqual"></a>Array   数组   allEqual</h3><p>检查数组中的所有元素是否相等。使用  Array.prototype.every（） 检查数组中的所有元素是否与第一个元素相同。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> allEqual = <span class="function"><span class="params">arr</span> =&gt;</span> arr.every( <span class="function"><span class="params">val</span> =&gt;</span> val === arr[<span class="number">0</span>]);</span><br><span class="line"><span class="built_in">console</span>.log(allEqual([<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]));<span class="comment">//false</span></span><br><span class="line"><span class="built_in">console</span>.log(allEqual([<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>]));<span class="comment">//true</span></span><br></pre></td></tr></table></figure>
<h3 id="Array-数组-any"><a href="#Array-数组-any" class="headerlink" title="Array   数组   any"></a>Array   数组   any</h3><p>如果提供的谓词函数对集合中的至少一个元素返回  true  ，则返回  true   ，否则返回  false   。使用 Array.prototype.some（） 测试集合中的任何元素是否基于  fn  返回  true 。省略第二个参数  fn ，将布尔值用作默认值。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> any = <span class="function">(<span class="params">arr, fn = <span class="built_in">Boolean</span></span>) =&gt;</span> arr.some(fn);+</span><br><span class="line"><span class="built_in">console</span>.log(any([<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">0</span>], x =&gt; x &gt;=<span class="number">2</span>));<span class="comment">//true</span></span><br><span class="line"><span class="built_in">console</span>.log(any([<span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">0</span>]));<span class="comment">//true</span></span><br></pre></td></tr></table></figure>
<h3 id="MDN-解析-Array-prototype-some-案例"><a href="#MDN-解析-Array-prototype-some-案例" class="headerlink" title="MDN  解析 Array.prototype.some()  案例"></a>MDN  解析 Array.prototype.some()  案例</h3><p>该   some ()   方法测试数组中是否至少有一个元素通过了由提供的函数实现的测试。此方法返回   false   放在空数组上的任何条件。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">console</span>.log([<span class="number">2</span>, <span class="number">5</span>, <span class="number">8</span>, <span class="number">1</span>, <span class="number">4</span>].some(<span class="function"><span class="params">x</span> =&gt;</span> x &gt; <span class="number">10</span>));<span class="comment">//false</span></span><br><span class="line"><span class="built_in">console</span>.log([<span class="number">12</span>, <span class="number">5</span>, <span class="number">8</span> ,<span class="number">1</span> , <span class="number">4</span>].some( <span class="function"><span class="params">x</span> =&gt;</span> x &gt;<span class="number">10</span>));<span class="comment">//true</span></span><br></pre></td></tr></table></figure>
<h3 id="Array-数组-arrayToCSV"><a href="#Array-数组-arrayToCSV" class="headerlink" title="Array   数组   arrayToCSV"></a>Array   数组   arrayToCSV</h3><p>将二维数组转换为逗号分隔值（  csv  ）字符串。使用 Array.prototype.map () 和  Array.prototype.join（delimiter）  将一维数组组合成字符串。使用   Array.prototype.join（’\n’） （  ，换行符号）两个组合的全行到  CSV  格式的字符串，每排分捡和一个换行符。在第二  omit  参数delimiter ，使用  delimiter（默认）。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> arrayToCSV = <span class="function">(<span class="params">arr, delimiter = <span class="string">','</span></span>) =&gt;</span> arr.map( <span class="function"><span class="params">v</span> =&gt;</span> v.map( <span class="function"><span class="params">x</span> =&gt;</span> <span class="string">`"<span class="subst">$&#123;x&#125;</span>"`</span>).join(delimiter)).join(<span class="string">'\n'</span>);</span><br><span class="line"></span><br><span class="line"><span class="built_in">console</span>.log(arrayToCSV([[<span class="string">'a'</span>, <span class="string">'b'</span>], [<span class="string">'c'</span>, <span class="string">'d'</span>]]));</span><br><span class="line"><span class="comment">//"a","b" </span></span><br><span class="line"><span class="comment">//"c","d"</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">console</span>.log(arrayToCSV([[<span class="string">'a'</span>, <span class="string">'b'</span>],[<span class="string">'c'</span>, <span class="string">'d'</span>]],<span class="string">';'</span>));</span><br><span class="line"><span class="comment">//"a","b" </span></span><br><span class="line"><span class="comment">//"c","d"</span></span><br></pre></td></tr></table></figure>
<h3 id="MDN-解析-Array-prototype-map-案例"><a href="#MDN-解析-Array-prototype-map-案例" class="headerlink" title="MDN  解析 Array.prototype.map()  案例"></a>MDN  解析 Array.prototype.map()  案例</h3><p>该   map()   方法创建一个新数组，其结果是在调用数组中的每个元素上调用提供的函数。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> array1 = [<span class="number">1</span>, <span class="number">4</span>, <span class="number">9</span> ,<span class="number">16</span>];</span><br><span class="line"><span class="keyword">const</span> map1 = array1.map(<span class="function"><span class="params">x</span> =&gt;</span> x * <span class="number">2</span>);</span><br><span class="line"><span class="built_in">console</span>.log(map1);<span class="comment">// [2, 8, 18, 32]</span></span><br><span class="line"><span class="built_in">console</span>.log(array1);<span class="comment">//[1, 4, 9, 16]</span></span><br></pre></td></tr></table></figure>
<h3 id="MDN-解析-Array-prototype-join-案例"><a href="#MDN-解析-Array-prototype-join-案例" class="headerlink" title="MDN  解析 Array.prototype.join()  案例"></a>MDN  解析 Array.prototype.join()  案例</h3><p>该  join()  方法通过连接数组（或类数组对象）中的所有元素（由逗号或指定的分隔符字符串分隔）来创建并返回新字符串。如果数组只有一个项目，那么将返回该项目而不使用分隔符。如果元素是  undefined  或  null ，则将其转换为空字符串。<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> elements = [<span class="string">'Fire'</span>, <span class="string">'Wind'</span>, <span class="string">'Rain'</span>];</span><br><span class="line"></span><br><span class="line"><span class="built_in">console</span>.log(<span class="built_in">console</span>.log(elements.join(<span class="string">'-'</span>)));<span class="comment">//Fire-Wind-Rain</span></span><br></pre></td></tr></table></figure></p>

            <!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->
            <audio id="audio" loop="1" preload="auto" controls="controls"
                data-autoplay="false">
                <source type="audio/mpeg" src="">
            </audio>
            
            <ul id="audio-list" style="display:none">
                
                
                <li title='0' data-url='/statics/chengdu.mp3'></li>
                
                    
            </ul>
            
            
            
    <div id='gitalk-container' class="comment link"
        data-ae='true'
        data-ci='ec894e2b66f752e8b7fb'
        data-cs='3ccc2e92bb350688fe2c2dc2930189b62622bfb1'
        data-r='blog-comments'
        data-o='TriDiamond'
        data-a='TriDiamond'
        data-d='undefined'
    >Comments</div>


            
            
        </div>
        <div class="sidebar">
            <div class="box animated fadeInRight">
                <div class="subbox">
                    <img src="https://res.cloudinary.com/tridiamond/image/upload/v1573019751/TriDiamond_logo_ui_xeublz.jpg" height=300 width=300></img>
                    <p>张白告丶</p>
                    <span>Think like an artist, develop like an artisan</span>
                    <dl>
                        <dd><a href="https://github.com/zhanghao-web" target="_blank"><span
                                    class=" iconfont icon-github"></span></a></dd>
                        <dd><a href="" target="_blank"><span
                                    class=" iconfont icon-twitter"></span></a></dd>
                        <dd><a href="" target="_blank"><span
                                    class=" iconfont icon-stack-overflow"></span></a></dd>
                    </dl>
                </div>
                <ul>
                    <li><a href="/">149 <p>Articles</p></a></li>
                    <li><a href="/categories">23 <p>Categories</p></a></li>
                    <li><a href="/tags">47 <p>Tags</p></a></li>
                </ul>
            </div>
            
            
            
            <div class="box sticky animated fadeInRight faster">
                <div id="toc" class="subbox">
                    <h4>Contents</h4>
                    <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#项目背景简介"><span class="toc-number">1.</span> <span class="toc-text">项目背景简介</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#学习初衷"><span class="toc-number">1.1.</span> <span class="toc-text">学习初衷</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#学习方法"><span class="toc-number">1.2.</span> <span class="toc-text">学习方法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Adapter-适配器-ary"><span class="toc-number">1.2.1.</span> <span class="toc-text">Adapter 适配器 ary</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#MDN-解析-Array-prototype-slice-案例"><span class="toc-number">1.2.2.</span> <span class="toc-text">MDN 解析 Array.prototype.slice() 案例</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#MDN-解析-Math-max-案例"><span class="toc-number">1.2.3.</span> <span class="toc-text">MDN 解析 Math.max() 案例</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Array-数组-all"><span class="toc-number">1.2.4.</span> <span class="toc-text">Array   数组   all</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#MDN-解析-Array-prototype-every-案例"><span class="toc-number">1.2.5.</span> <span class="toc-text">MDN  解析 Array.prototype.every()  案例</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Array-数组-allEqual"><span class="toc-number">1.2.6.</span> <span class="toc-text">Array   数组   allEqual</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Array-数组-any"><span class="toc-number">1.2.7.</span> <span class="toc-text">Array   数组   any</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#MDN-解析-Array-prototype-some-案例"><span class="toc-number">1.2.8.</span> <span class="toc-text">MDN  解析 Array.prototype.some()  案例</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Array-数组-arrayToCSV"><span class="toc-number">1.2.9.</span> <span class="toc-text">Array   数组   arrayToCSV</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#MDN-解析-Array-prototype-map-案例"><span class="toc-number">1.2.10.</span> <span class="toc-text">MDN  解析 Array.prototype.map()  案例</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#MDN-解析-Array-prototype-join-案例"><span class="toc-number">1.2.11.</span> <span class="toc-text">MDN  解析 Array.prototype.join()  案例</span></a></li></ol></li></ol></li></ol>
                </div>
            </div>
            
            
        </div>
    </div>
</div>

    </div>
</div>
    <div id="back-to-top" class="animated fadeIn faster">
        <div class="flow"></div>
        <span class="percentage animated fadeIn faster">0%</span>
        <span class="iconfont icon-top02 animated fadeIn faster"></span>
    </div>
</body>
<footer>
    <p class="copyright" id="copyright">
        &copy; 2020
        <span class="gradient-text">
            张白告丶
        </span>.
        Powered by <a href="http://hexo.io/" title="Hexo" target="_blank" rel="noopener">Hexo</a>
        Theme
        <span class="gradient-text">
            <a href="https://github.com/TriDiamond/hexo-theme-obsidian" title="Obsidian" target="_blank" rel="noopener">Obsidian</a>
        </span>
        <small><a href="https://github.com/TriDiamond/hexo-theme-obsidian/blob/master/CHANGELOG.md" title="v1.4.3" target="_blank" rel="noopener">v1.4.3</a></small>
    </p>
</footer>

<script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script>
  MathJax.Hub.Config({
    "HTML-CSS": {
      preferredFont: "TeX",
      availableFonts: ["STIX", "TeX"],
      linebreaks: {
        automatic: true
      },
      EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50)
    },
    tex2jax: {
      inlineMath: [
        ["$", "$"],
        ["\\(", "\\)"]
      ],
      processEscapes: true,
      ignoreClass: "tex2jax_ignore|dno",
      skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    },
    TeX: {
      noUndefined: {
        attributes: {
          mathcolor: "red",
          mathbackground: "#FFEEEE",
          mathsize: "90%"
        }
      },
      Macros: {
        href: "{}"
      }
    },
    messageStyle: "none"
  });
</script>
<script>
  function initialMathJax() {
    MathJax.Hub.Queue(function () {
      var all = MathJax.Hub.getAllJax(),
        i;
      // console.log(all);
      for (i = 0; i < all.length; i += 1) {
        console.log(all[i].SourceElement().parentNode)
        all[i].SourceElement().parentNode.className += ' has-jax';
      }
    });
  }

  function reprocessMathJax() {
    if (typeof MathJax !== 'undefined') {
      MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
    }
  }
</script>



    
<link rel="stylesheet" href="//cdn.bootcss.com/gitalk/1.5.0/gitalk.min.css">

    
<script src="//cdn.bootcss.com/gitalk/1.5.0/gitalk.min.js"></script>



<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="/js/plugin.js"></script>
<script src="/js/obsidian.js"></script>
<script src="/js/jquery.truncate.js"></script>
<script src="/js/search.js"></script>


<script src="//cdn.bootcss.com/typed.js/2.0.10/typed.min.js"></script>


<script src="//cdn.bootcss.com/blueimp-md5/2.12.0/js/md5.min.js"></script>


<script src="//cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/js/social-share.min.js"></script>


<script src="https://cdn.bootcss.com/codemirror/5.48.4/codemirror.min.js"></script>

    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/javascript/javascript.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/css/css.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/xml/xml.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/htmlmixed/htmlmixed.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/clike/clike.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/php/php.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/shell/shell.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/python/python.min.js"></script>




    
<script src="/js/busuanzi.min.js"></script>

    <script>
        $(document).ready(function () {
            if ($('span[id^="busuanzi_"]').length) {
                initialBusuanzi();
            }
        });
    </script>



<link rel="stylesheet" href="//cdn.bootcss.com/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="//cdn.bootcss.com/photoswipe/4.1.3/default-skin/default-skin.min.css">


<script src="//cdn.bootcss.com/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="//cdn.bootcss.com/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>
    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">
        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <!--  Controls are self-explanatory. Order can be changed. -->
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>



    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="//www.googletagmanager.com/gtag/js?id=UA-149874671-1"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());

        gtag('config', 'UA-149874671-1');
    </script>





<script>
    function initialTyped () {
        var typedTextEl = $('.typed-text');
        if (typedTextEl && typedTextEl.length > 0) {
            var typed = new Typed('.typed-text', {
                strings: ["Think like an artist, develop like an artisan", "艺术家思维去思考问题，工匠创造精神去开发"],
                typeSpeed: 90,
                loop: true,
                loopCount: Infinity,
                backSpeed: 20,
            });
        }
    }

    if ($('.article-header') && $('.article-header').length) {
        $(document).ready(function () {
            initialTyped();
        });
    }
</script>




</html>
